﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//using System.Web.Script.Services;
using System.Web.Services;
using Telerik.Web.UI;
using System.Data;
using System.Collections;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.MODEL;

namespace KPIS.GERP.GHRMS.APP.App_UI.Controls
{
    public partial class EducationInstituteCombo : System.Web.UI.UserControl
    {
        private IMasEducationInstituteBLL BLL = new MasEducationInstituteBLL();
        private const int ItemsPerRequest = 10;
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        public void ListEduInstituteComboBox()
        {
            // RadComboBoxData GetInstituteComboBox();
            //IList<MasEducationInstituteInfo> InfoList = BLL.ListEducationInstitutes();

            //cbEduInstitute.DataSource = InfoList;
            //cbEduInstitute.DataBind();
        }
        public void cbEduInstitute_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
        {
            DataTable data = CreateTable();

            int itemOffset = e.NumberOfItems;
            int endOffset = Math.Min(itemOffset + ItemsPerRequest, data.Rows.Count);
            e.EndOfItems = endOffset == data.Rows.Count;

            for (int i = itemOffset; i < endOffset; i++)
            {
                cbEduInstitute.Items.Add(new RadComboBoxItem(data.Rows[i]["Name"].ToString(), data.Rows[i]["Sequence"].ToString()));
            }

            e.Message = GetStatusMessage(endOffset, data.Rows.Count);
        }
        private static string GetStatusMessage(int offset, int total)
        {
            if (total <= 0)
                return "No matches";

            return String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", offset, total);
        }
        public DataTable CreateTable()
        {
            IList<MasEducationInstituteInfo> InfoList = BLL.ListEducationInstitutes();
            DataTable table = new DataTable();
            
            foreach (MasEducationInstituteInfo List in InfoList)
            {
                table.Columns.Add("Sequence", typeof(int));
                table.Columns.Add("Name", typeof(string));
            }

            return table;
        }

        //private static DataTable GetData()
        //{
        //    SqlDataAdapter adapter = new SqlDataAdapter("SELECT * from Customers WHERE CompanyName LIKE @text + '%'",
        //        ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
        //    adapter.SelectCommand.Parameters.AddWithValue("@text", text);

        //    DataTable data = new DataTable();
        //    data.Columns[""].
        //    adapter.Fill(data);

        //    return data;
        //}


        //protected void Page_Load(object sender, EventArgs e)
        //{
        //}
        //public void ListEduInstituteComboBox()
        //{
        //   // RadComboBoxData GetInstituteComboBox();
        //    //IList<MasEducationInstituteInfo> InfoList = BLL.ListEducationInstitutes();

        //    //cbEduInstitute.DataSource = InfoList;
        //    //cbEduInstitute.DataBind();
        //}
        

    }
}